<link rel="stylesheet" href="/assets/css/m.css"/>
<div class="tpl-portlet-components" xmlns:th="http://www.thymeleaf.org">
    <div class="portlet-title">
        <div class="caption font-green bold">
            保存新闻
        </div>
    </div>
    <div class="tpl-block ">
        <div class="am-g tpl-amazeui-form">
            <div class="am-u-sm-12 am-u-md-9">
                <form class="am-form am-form-horizontal" id="movieNewsFormId">
                    <input type="hidden" name="id" th:value="${news==null?0:news.id}">
                    <div class="am-form-group">
                        <label for="movieLanguageFormId" class="am-u-sm-3 am-form-label">新闻标题 / News Title</label>
                        <div class="am-u-sm-9">
                            <input type="text" id="movieLanguageFormId" name="title" placeholder="新闻标题"
                                   th:value="${news == null ? '测试新闻标题' : news.title}">
                        </div>
                    </div>
                    <div class="am-form-group">
                        <label for="movieLanguageFormId" class="am-u-sm-3 am-form-label">新闻内容 / News Content</label>
                        <div class="am-u-sm-9">
                            <textarea class="ckeditor" id="editor1" title="title"
                                      th:text="${news==null?'测试内容':news.content}">测试内容
                            </textarea>
                        </div>
                    </div>
                    <div class="am-form-group">
                        <label class="am-u-sm-3 am-form-label">新闻插图 <span
                                class="tpl-form-line-small-title">Movie Covers</span></label>
                        <div class="am-u-sm-9">
                            <div class="am-form-group am-form-file">
                                <button type="button" class="am-btn am-btn-danger am-btn-sm">
                                    <i class="am-icon-cloud-upload"></i> 添加插图
                                </button>
                                <input type="hidden" name="imageFileName"
                                       th:value="${news==null?'default.jpg':news.imageFileName}">
                                <input id="imageFile" type="file">
                                <span id="fileName" style="color: red"></span>
                            </div>
                        </div>
                    </div>
                    <div class="am-form-group">
                        <div class="am-u-sm-9 am-u-sm-push-3">
                            <button type="button" onclick="saveMovieNews()" class="am-btn am-btn-primary">保存新闻
                            </button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script>
    ckEditor = CKEDITOR.replace('editor1');
    //添加图片选择事件
    $('#imageFile').on('change', function () {
        $.each(this.files, function () {
            $("#fileName").text(this.name);
        });
    });
</script>